//
//  AboutViewController.m
//  CarNetwork
//
//  Created by fzuacm on 16/4/18.
//  Copyright © 2016年 fzu_z. All rights reserved.
//

#import "AboutViewController.h"
#import "carSelectTableViewCell.h"
#import "WebViewController.h"

@interface AboutViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    UIImageView *_imageView;
    UITableView *_TableView;
}

@end

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatTableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma view
-(void)creatTableView
{
    _TableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64)];
    _TableView.dataSource = self;
    _TableView.delegate = self;
    _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"default.png"]]];
    
    _TableView.backgroundColor = [UIColor clearColor];
    [_TableView setBackgroundView:_imageView];
    [self.view addSubview:_TableView];
    
}


#pragma delegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellID =@"carSelectTableViewCell";
    carSelectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    cell.backgroundColor = nil;
    if (!cell) {
        cell= [[[NSBundle mainBundle] loadNibNamed:cellID owner:self options:nil] lastObject];
        cell.selectLabel.textColor = [UIColor blackColor];
        
        switch (indexPath.row+1) {
            case 1:
                cell.selectLabel.text = [NSString stringWithFormat:@"%d.%@",indexPath.row+1,[NSString stringWithFormat:@"法拉利f70"]];
                break;
            case 2:
                cell.selectLabel.text = [NSString stringWithFormat:@"%d.%@",indexPath.row+1,[NSString stringWithFormat:@"布加迪威龙super sport"]];
                break;
            case 3:
                cell.selectLabel.text = [NSString stringWithFormat:@"%d.%@",indexPath.row+1,[NSString stringWithFormat:@"迈巴赫Landaulet"]];
                break;
                
            default:
                break;
        }
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIBarButtonItem *item = [[UIBarButtonItem alloc] init];
    item.title=@"我的车库";
    self.navigationItem.backBarButtonItem=item;
    
    switch (indexPath.row+1) {
        case 1:
        {
            WebViewController *mycar = [[WebViewController alloc] initWithUrl:@"http://baike.baidu.com/link?url=xanmGuiqeJ2_eSZg8ov1b8iFB8RixS6qYJk1986xYZCV0zl_oZk2orte1mfz7orK2ilsVb_lZpwRvQa4hdJy3K"];
            mycar.title=@"法拉利f70";
            [self.navigationController pushViewController:mycar animated:YES];
            
        }
            break;
        case 2:
        {
            WebViewController *mycar = [[WebViewController alloc] initWithUrl:@"http://baike.baidu.com/link?url=IKuK4xf5l-rgSSG7nBxfVzIau6_Nh1RJHJv1FIHV_R9WP-nic2rN_kSi1nDgHLZOX2-SomJl4_e4jGA_UI4CFK"];
            mycar.title=@"布加迪威龙super sport";
            [self.navigationController pushViewController:mycar animated:YES];
        }
            break;
        case 3:
        {
            WebViewController *mycar = [[WebViewController alloc] initWithUrl:@"http://baike.baidu.com/link?url=-kr68RMdW5hoSlxZcAwTfdTiTP_0Y_mi4jq0h7MZXUb2kdw2VAlf4W34-d2d7Gnh1cAbAoU5wYK4rf9NNxhmVK"];
            mycar.title=@"迈巴赫Landaulet";
            [self.navigationController pushViewController:mycar animated:YES];
        }
            break;
            
        default:
            break;
    }
    //进入汽车详细界面
    /*task:
     A:可维护多辆个人汽车。
     B:假设汽车屏幕可提供此车辆当前信息的二维码,可供用户扫码，APP可扫码并把个人汽车信息维护到手机里面。（因此要求参赛者自己生成一个二维码，然后通过手机扫码完成此功能。）
     C:信息包含但不限于：汽车品牌、标志、型号、车牌号码、发动机号、车身级别（几门几座）、里程数、汽油量（%）、发动机性能（好、异常）、变速器性能（好、异常），车灯（好、坏）。
     D:汽车信息也需要维护到服务器端的数据库里。
     E: 要求把以下通知及时推送到手机端
     a.     当服务器端的数据库里记录的汽油量少于20%时，给手机发送通知告诉汽车车主该去加油
     b.     当服务器端的数据库里记录的里程数每超过15000公里倍数时，给手机发送通知告诉汽车车主需要进行维护
     c.     当服务器端的数据库里记录的发动机出现异常、变速器出现异常或车灯有坏的时候，给手机发送通知告诉汽车车主需要进行维修
     */
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
